/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	Logic.h
*
*	Description -	The application logic where all data structures related to the
*						applications are located. 
*
*	Comments	-
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	06/16/2011	-	Creation of this file
**************************************************************************************/

#ifndef _PSX_LOGIC_H_
#define _PSX_LOGIC_H_

#include "PulseSTD.h"
#include "ProcessManager.h"
#include "Application.h"
#include "FactoryActor.h"

namespace Pulse
{
	class Logic
	{
	public:

		Logic( void );

		virtual ~Logic( void );

		/////////
		virtual EErrorCode::Type OnInitialize( void ) { return EErrorCode::OKAY; }
		
		virtual void OnShutdown( void ) { }

		virtual void OnUpdate( DOUBLE time, FLOAT dt ) { }
		/////////

		Application * GetApplication( void ) { return m_pApp; }

		void AddProcess( Process::ProcessPointer pProcess );

	private:

		friend class Engine;
		friend class Application;

		void Update( DOUBLE time, FLOAT dt );

		////////////////////////////////////////////////
		EErrorCode::Type Initialize( Application *pApp );

		void Shutdown( void );

	protected:

		Application		*m_pApp;
		ProcessManager	*m_pProcessManager;
	};

	PSX_INLINE void Logic::AddProcess( Process::ProcessPointer pProcess )
	{
		m_pProcessManager->AddProcess( pProcess );
	}

}

#endif /* _PSX_LOGIC_H_ */